angular.module('mamApp').factory('ProgramsManager', ['$http', 'api', 'paramsManager', function ($http, api, paramsManager) {
    var ProgramsManager = {
        /**
         * 节目列表
         * @param params
         * @returns
         */

        programsList: function (albumId, params, query) {
            return $http.get(api + '/cp/album/' + albumId + '/programs/' + paramsManager.params(params) + paramsManager.query(query)).then(function (result) {
                return result;
            });
        },
        /**
         * 节目删除
         * @param programId
         * @returns
         */

        programDelete: function (programId) {
            return $http.delete(api + '/cp/programs/' + programId).then(function (result) {
                return result;
            });
        }  ,
        /**
         * 节目详情
         * @param programId
         * @returns
         */

        programDetail: function (programId) {
            return $http.get(api + '/cp/programs/' + programId).then(function (result) {
                return result;
            });
        }  ,
        /**
         * 节目修改
         * @param programId
         * @returns
         */

        programEdit: function (programId,params) {
            return $http.put(api + '/cp/programs/' + programId,params).then(function (result) {
                return result;
            });
        }, 
        /**
         * 重传音频
         * @param programId
         * @returns
         */

        programReUpload: function (programId,params) {
            return $http.put(api + '/cp/programs/reupload/' + programId,params).then(function (result) {
                return result;
            });
        },
        /**
         * 添加单个节目
         * @param params
         * @returns
         */

        programSingleAdd: function (albumId,params) {
            return $http.post(api+'/cp/album/'+ albumId +'/programs/single', params).then(function (result) {
                return result;
            });
        },
        /**
         * 添加多个节目
         * @param params
         * @returns
         */

        programBatchAdd: function (albumId,params) {
            return $http.post(api+'/cp/album/'+ albumId +'/programs/batch', params).then(function (result) {
                return result;
            });
        },
        /**
         * 节目调序
         * @param params
         * albumId
         * targetId
         * targetSort
         * ownId
         * ownSort
         * @returns
         */

        programSort: function (albumId,params) {
            return $http.put(api+'/cp/album/'+albumId+'/programSort', params).then(function (result) {
                return result;
            });
        }

    };

    return ProgramsManager;
}]);
